//
// RTL: Button groups
// --------------------------------------------------

.btn-group {
  > .btn {
    float: right;
  }

  .btn + .btn,
  .btn + .btn-group,
  .btn-group + .btn,
  .btn-group + .btn-group {
    margin-left: 0;
    margin-right: -1px;
  }

  .dropdown-toggle {
    margin-bottom: -1px;
  }
}

.btn-group.btn-group-justified > .btn {
  float: none;
}

.btn-toolbar {
  .btn-group {
    float: right;

    &.btn-group-justified {
      float: none;
    }
  }
  > .btn,
  > .btn-group {
    margin-left: 0;

    + .btn,
    + .btn-group {
      margin-left: 0;
      margin-right: 5px;
    }
  }
}

.btn-group > .btn:first-child {
  margin-right: 0;
}

.btn-group > .btn-group {
  float: right;
}


//  Borders
//

.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
  border-radius: $border-radius-base;
  @include border-left-radius(0);
}
.btn-group > .btn:last-child:not(:first-child), .btn-group > .dropdown-toggle:not(:first-child) {
  border-radius: $border-radius-base;
  @include border-right-radius(0);
}
.btn-group > .btn-group:first-child { > .btn:last-child, > .dropdown-toggle {
  border-radius: $border-radius-base;
  @include border-left-radius(0);
} }
.btn-group > .btn-group:last-child > .btn:first-child {
  border-radius: $border-radius-base;
  @include border-right-radius(0);
}


.btn-group-lg > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
  border-radius: $border-radius-large;
  @include border-left-radius(0);
}
.btn-group-lg > .btn:last-child:not(:first-child), .btn-group-lg > .dropdown-toggle:not(:first-child) {
  border-radius: $border-radius-large;
  @include border-right-radius(0);
}
.btn-group-lg > .btn-group:first-child { > .btn:last-child, > .dropdown-toggle {
  border-radius: $border-radius-large;
  @include border-left-radius(0);
} }
.btn-group-lg > .btn-group:last-child > .btn:first-child {
  border-radius: $border-radius-large;
  @include border-right-radius(0);
}


.btn-group-sm > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
  border-radius: $border-radius-small;
  @include border-left-radius(0);
}
.btn-group-sm > .btn:last-child:not(:first-child), .btn-group-sm > .dropdown-toggle:not(:first-child) {
  border-radius: $border-radius-small;
  @include border-right-radius(0);
}
.btn-group-sm > .btn-group:first-child { > .btn:last-child, > .dropdown-toggle {
  border-radius: $border-radius-small;
  @include border-left-radius(0);
} }
.btn-group-sm > .btn-group:last-child > .btn:first-child {
  border-radius: $border-radius-small;
  @include border-right-radius(0);
}


.btn-group.btn-xs > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
  border-radius: $border-radius-small;
  @include border-left-radius(0);
}
.btn-group-xs > .btn:last-child:not(:first-child), .btn-group-xs > .dropdown-toggle:not(:first-child) {
  border-radius: $border-radius-small;
  @include border-right-radius(0);
}
.btn-group-xs > .btn-group:first-child { > .btn:last-child, > .dropdown-toggle {
  border-radius: $border-radius-small;
  @include border-left-radius(0);
} }
.btn-group-xs > .btn-group:last-child > .btn:first-child {
  border-radius: $border-radius-small;
  @include border-right-radius(0);
}
